<%@ page pageEncoding="UTF-8"%>

<script type="text/javascript">
	var url;
	function newUser(){
	    $('#dlg').dialog('open').dialog('setTitle', '食材类别添加');
	    $('#fm').form('clear');
	    url = '${pageContext.request.contextPath}/dwr/jsonp/FoodTypeService/add';
	}
	function editUser(){
	    var row = $('#dg').datagrid('getSelected');
	    if (row){
	        $('#dlg').dialog('open').dialog('setTitle', '食材类别修改');
	        $('#fm').form('load', row);
	        url = '${pageContext.request.contextPath}/dwr/jsonp/FoodTypeService/modify?id=';
	    }
	}
	function saveUser(){
	    $('#fm').form('submit',{
	        url: url,
	        onSubmit: function(){
	            return $(this).form('validate');
	        },
	        success: function(result){
	            var result = eval('('+result+')');
	            if (result.errorMsg){
	                $.messager.show({
	                    title: 'Error',
	                    msg: result.errorMsg
	                });
	            } else {
	                $('#dlg').dialog('close');        // close the dialog
	                $('#dg').datagrid('reload');    // reload the user data
	            }
	        }
	    });
	}
</script>

<div style="padding: 2px 5px;" cellspacing="5">
	<table >
		<tr>
			<td>类别名称：</td><td><input class="easyui-textbox" type="text" name="name"></input></td>
			<td>类别名称：</td><td><input class="easyui-textbox" type="text" name="name"></input></td>
			<td><a href="#" class="easyui-linkbutton" iconCls="icon-search" style="width: 80px;">查 询</a></td>
		</tr>
	</table>
	
	<table class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,url:'',method:'get',toolbar:'#tb'">
		<thead>
			<tr>
				<th data-options="field:'itemid',width:200">类别名称</th>
			</tr>
		</thead>
	</table>
	
	<div id="tb" style="padding: 2px 5px;">
		<a href="javascript:void(0)" onclick="newUser()" class="easyui-linkbutton" iconCls="icon-add" plain="true"></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true"></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true"></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cut" plain="true"></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true"></a>
	</div>
</div>

<div id="dlg" class="easyui-dialog" style="padding: 20px" closed="true" buttons="#dlg-buttons">
	<form id="fm" method="post" novalidate>
		<input type="hidden" name="id"/>
		<div class="fitem">
			<label>First Name:</label> <input name="name" class="easyui-textbox" required="true">
		</div>
	</form>
</div>
<div id="dlg-buttons">
	<a href="javascript:void(0)" class="easyui-linkbutton c1" iconCls="icon-ok" onclick="saveUser()" style="width: 90px">Save</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width: 90px">Cancel</a>
</div>
